<template>
  <div id="div_body">
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px"
        label-position="left">
      <el-row :gutter="15">
        <el-col :span="12">
          <el-form-item label="训练数据：" prop="train_data">
            <el-checkbox-group v-model="formData.train_data" :min="1" size="medium">
              <el-checkbox v-for="(item, index) in train_dataOptions" :key="index" :label="item.value"
                :disabled="item.disabled">{{item.label}}</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="筛选逻辑：" prop="filter_logic">
            <el-checkbox-group v-model="formData.filter_logic" :min="1" size="medium">
              <el-checkbox v-for="(item, index) in filter_logicOptions" :key="index" :label="item.value"
                :disabled="item.disabled">{{item.label}}</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="15">
          <el-col :span="12">
            <el-form-item label="抽取逻辑：" prop="trained_times">
              已训练次数&lt;<el-input-number v-model="formData.trained_times"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="训练次数" prop="field124">
              <el-input-number v-model="formData.field124" placeholder="训练次数"></el-input-number>
            </el-form-item>
            <el-form-item label="计数方式" prop="count_type">
              <el-radio-group v-model="formData.count_type" size="medium">
                <el-radio v-for="(item, index) in count_typeOptions" :key="index" :label="item.value"
                  :disabled="item.disabled">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="15">
          <el-col :span="12">
            <el-form-item label="项目功能：" prop="field118">
              <el-cascader v-model="formData.field118" :options="field118Options" :props="field118Props"
                :style="{width: '100%'}" placeholder="请选择项目功能：" clearable></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="启用" prop="field101" required>
              <el-switch v-model="formData.field101"></el-switch>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="按钮" prop="field126">
              <el-button type="primary" icon="el-icon-search" size="medium"> 主要按钮 </el-button>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item size="large">
              <el-button type="primary" @click="submitForm">提交</el-button>
              <el-button @click="resetForm">重置</el-button>
            </el-form-item>
          </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
export default {
  components: {},
  props: [],
  data() {
    return {
      formData: {
        train_data: [""],
        filter_logic: [""],
        field124: -2,
        count_type: 1,
        trained_times: undefined,
        field118: [],
        field101: false,
        field126: undefined,
      },
      rules: {
        train_data: [{
          required: true,
          type: 'array',
          message: '请至少选择一个train_data',
          trigger: 'change'
        }],
        filter_logic: [{
          required: true,
          type: 'array',
          message: '请至少选择一个filter_logic',
          trigger: 'change'
        }],
        field124: [{
          required: true,
          message: '训练次数',
          trigger: 'blur'
        }],
        count_type: [{
          required: true,
          message: '计数方式不能为空',
          trigger: 'change'
        }],
        trained_times: [{
          required: true,
          message: '抽取逻辑（已训练次数）',
          trigger: 'blur'
        }],
        field118: [{
          required: true,
          type: 'array',
          message: '请至少选择一个field118',
          trigger: 'change'
        }],
      },
      train_dataOptions: [{
        "label": "功能-测试点",
        "value": 1
      }, {
        "label": "测试点-用例",
        "value": 2
      }],
      filter_logicOptions: [{
        "label": "用户新增",
        "value": 1
      }, {
        "label": "用户修改",
        "value": 2
      }, {
        "label": "已评审",
        "value": 3
      }],
      count_typeOptions: [{
        "label": "固定",
        "value": 1
      }, {
        "label": "补足",
        "value": 2
      }],
      field118Options: [],
      field118Props: {
        "multiple": false
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
    getField118Options() {
      // TODO 发起请求获取数据
      this.field118Options
    },
  }
}

</script>
<style>
  #div_body{
    margin: 15px;
  }
</style>
